home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / tclX6.4c / dist / tests / list.test < prev    next >
Encoding:
Text File  |  1992-11-07  |  4.1 KB  |  185 lines

  1. #
  2. # list.test
  3. #
  4. # Tests for the lvarpop command.
  5. #---------------------------------------------------------------------------
  6. # Copyright 1992 Karl Lehenbauer and Mark Diekhans.
  7. #
  8. # Permission to use, copy, modify, and distribute this software and its
  9. # documentation for any purpose and without fee is hereby granted, provided
  10. # that the above copyright notice appear in all copies.  Karl Lehenbauer and
  11. # Mark Diekhans make no representations about the suitability of this
  12. # software for any purpose.  It is provided "as is" without express or
  13. # implied warranty.
  14. #------------------------------------------------------------------------------
  15. # $Id: list.test,v 2.0 1992/10/16 04:49:59 markd Rel $
  16. #------------------------------------------------------------------------------
  17. #
  18.  
  19. if {[info procs test] != "test"} then {source testlib.tcl}
  20.  
  21. Test list-1.1 {lvarpop tests} {
  22.     set a {a b c d e f g h i j}
  23.     list [lvarpop a 0] $a
  24. } 0 {a {b c d e f g h i j}}
  25.  
  26. Test list-1.2 {lvarpop tests} {
  27.     set a {a bbbbbb c d e f g h i j}
  28.     list [lvarpop a 1] $a
  29. } 0 {bbbbbb {a c d e f g h i j}}
  30.  
  31. Test list-1.3 {lvarpop tests} {
  32.     set a {a bbbbbb c d e f g h i j}
  33.     list [lvarpop a 4] $a
  34. } 0 {e {a bbbbbb c d f g h i j}}
  35.  
  36. Test list-1.4 {lvarpop tests} {
  37.     set a {a bbbbbb c d e f g h i j}
  38.     list [lvarpop a 2 frobozz] $a
  39. } 0 {c {a bbbbbb frobozz d e f g h i j}}
  40.  
  41. Test list-1.5 {lvarpop tests} {
  42.     set a {a bbbbbb frozbozz d e f g h i j}
  43.     list [lvarpop a 2 f] $a
  44. } 0 {frozbozz {a bbbbbb f d e f g h i j}}
  45.  
  46. Test list-1.6 {lvarpop tests} {
  47.     set a {a bbbbbb c d e f g h i j}
  48.     list [lvarpop a 20 frobozz] $a
  49. } 0 {{} {a bbbbbb c d e f g h i j}}
  50.  
  51. Test list-1.7 {lvarpop tests} {
  52.     set a {}
  53.     list [lvarpop a] $a
  54. } 0 {{} {}}
  55.  
  56. Test list-1.8 {lvarpop tests} {
  57.     set a "a bbbbbb \{a"
  58.     lvarpop a 2 frobozz
  59. } 1 {unmatched open brace in list}
  60.  
  61. Test list-1.9 {lvarpop tests} {
  62.     lvarpop
  63. } 1 {wrong # args: lvarpop var [index [string]]}
  64.  
  65. Test list-1.10 {lvarpop tests} {
  66.     unset a
  67.     lvarpop a
  68. } 1 {can't read "a": no such variable}
  69.  
  70.  
  71. Test list-2.1 {lvarpush tests} {
  72.     set a {a b c d e f g h i j}
  73.     lvarpush a "xxx"
  74.     set a
  75. } 0 {xxx a b c d e f g h i j}
  76.  
  77. Test list-2.2 {lvarpush tests} {
  78.     set a {a c d e f g h i j}
  79.     lvarpush a b 1
  80.     set a
  81. } 0 {a b c d e f g h i j}
  82.  
  83. Test list-2.3 {lvarpush tests} {
  84.     set a {a bbbbbb c d f g h i j}
  85.     lvarpush a e 4
  86.     set a
  87. } 0 {a bbbbbb c d e f g h i j}
  88.  
  89. Test list-2.4 {lvarpush tests} {
  90.     set a {a bbbbbb c d e f g h i j}
  91.     lvarpush a frobozz 2
  92.     set a
  93. } 0 {a bbbbbb frobozz c d e f g h i j}
  94.  
  95. Test list-2.5 {lvarpush tests} {
  96.     set a {a b c d}
  97.     lvarpush a e 4
  98.     set a
  99. } 0 {a b c d e}
  100.  
  101. Test list-2.6 {lvarpush tests} {
  102.     set a {a b c d}
  103.     lvarpush a e 4
  104.     set a
  105. } 0 {a b c d e}
  106.  
  107. Test list-2.7 {lvarpush tests} {
  108.     set a {a b c d}
  109.     lvarpush a e 14
  110.     set a
  111. } 0 {a b c d e}
  112.  
  113. Test list-2.8 {lvarpush tests} {
  114.     set a "a bbbbbb \{a"
  115.     lvarpush a 2 frobozz
  116. } 1 {unmatched open brace in list}
  117.  
  118. Test list-2.9 {lvarpush tests} {
  119.     set a {}
  120.     lvarpush a a
  121.     set a
  122. } 0 {a}
  123.  
  124. Test list-2.10 {lvarpush tests} {
  125.     unset a
  126.     lvarpush a a
  127.     set a
  128. } 0 {a}
  129.  
  130. Test list-2.11 {lvarpush tests} {
  131.     set a "a bbbbbb \{a"
  132.     lvarpush a 2 frobozz
  133. } 1 {unmatched open brace in list}
  134.  
  135. Test list-2.12 {lvarpush tests} {
  136.     lvarpush
  137. } 1 {wrong # args: lvarpush var string [index]}
  138.  
  139.  
  140. Test list-3.1 {lvarcat} {
  141.     unset a
  142.     lvarcat a a b c d e f g
  143.     set a
  144. } 0 {a b c d e f g}
  145.  
  146. Test list-3.2 {lvarcat} {
  147.     unset a
  148.     lvarcat a a b c d e f g
  149. } 0 {a b c d e f g}
  150.  
  151. Test list-3.3 {lvarcat} {
  152.     unset a
  153.     lvarcat a a {b c d} {e f g h}
  154.     set a
  155. } 0 {a b c d e f g h}
  156.  
  157. Test list-3.4 {lvarcat} {
  158.     unset a
  159.     lvarcat a a {b c d} {e f g h}
  160. } 0 {a b c d e f g h}
  161.  
  162. Test list-3.5 {lvarcat} {
  163.     unset a
  164.     lvarcat a a {b {c d}}
  165.     lvarcat a {{e f}} g h
  166.     set a
  167. } 0 {a b {c d} {e f} g h}
  168.  
  169. Test list-3.6 {lvarcat} {
  170.     unset a
  171.     lvarcat a a\{ {b \{c d} \{d
  172.     set a
  173. } 0 "a{ b \\{c d {d"
  174.  
  175. Test list-3.7 {lvarcat} {
  176.     lvarcat a
  177. } 1 {wrong # args: lvarcat var string [string...]}
  178.  
  179. Test list-3.8 {lvarcat} {
  180.     lvarcat
  181. } 1 {wrong # args: lvarcat var string [string...]}
  182.  
  183.  
  184.  
  185.